﻿@using Windvoice.Albums;
@{
    ViewBag.Title = "Photo Upload";
    Layout = "~/Areas/Manage/Views/Shared/_Layout.cshtml";
}

@section headSection{
    <link href="/Content/css/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="/Content/js/jquery.uploadify.js" type="text/javascript"></script>
    <script src="/Content/js/swfobject.js" type="text/javascript"></script>
    <script src="/Content/js/jquery.cookie.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#file_upload').uploadify({
                'uploader': '/Content/flash/uploadify.swf',
                'script': '/manage/photo/reciever',
                'cancelImg': '/Content/images/uploadify-cancel.png',
                'scriptData': { 'album': $('#album').val(), 'batch': -1 },
                'multi': true,
                'onSelectOnce': function (event, data) {
                    $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
                },
                'onAllComplete': function (event, ID, fileObj, response, data) {
                    //$('#mainform').submit();
                    //window.location.href = '/manage/album/detail/' + $('#album').val();
                },
                'onError': function (event, ID, fileObj, errorObj) {
                    alert(errorObj.type + ' Error: ' + errorObj.info);
                }
            });

            $('#submitbutton').click(function () {
                alert($.cookie('ASP.NET_SessionId'));
                $("#file_upload").uploadifySettings('scriptData', { 'album': $('#album').val(), 'batch': -1, 'session': '@ViewBag.SessionID' });
                $('#file_upload').uploadifyUpload();
            });
        });
    </script>
}

<div class="pagetitle">
    <h2>上传照片</h2>
    <div class="pagefunctions">
        @Html.ActionLink("相册列表", "index","album")
    </div>    
</div>

@using (Html.BeginForm("detail", "album", FormMethod.Get, new { id="mainform",@class="dataform" }))
{
    <fieldset>
        <legend>选择照片</legend>
        <div class="editor-label">选择相册</div>
        <div class="editor-field">
            @Html.DropDownList("album", (from a in (Album[])ViewBag.AlbumList select new SelectListItem() { Text = a.AlbumName, Value = a.ID.ToString() }), new { id="album"})
            <a href="/manage/album/create">添加相册</a>
        </div>

        <div class="editor-label">选择照片</div>
        <div class="editor-field">
            <input id="file_upload" name="file_upload" type="file" />
        </div>

        <p>
            <input class="submitbutton" type="button" id="submitbutton" value="上传" />
        </p>
    </fieldset>
}